package com.joysuch.wwyt.common.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2020/5/29 15:26
 */
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_common_index_notify")
@SQLDelete(sql = "update wwyt_common_index_notify set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_common_index_notify set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@Accessors(chain = true)
public class CommonIndexNotify {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;

    @ApiModelProperty("关联证书人员表id--扩展：相关联表id")
    private Long eduCertUserId;

    @ApiModelProperty("人员id")
    private Long userId;

    @ApiModelProperty("人员姓名")
    @Transient
    private String userName;

    @ApiModelProperty("通知类型/来源")
    private String type;

    @ApiModelProperty("通知信息")
    private String notifyMessage;

    @ApiModelProperty("是否已读 0 未读; 1 已读")
    private Integer readFlag = 0;

    @ApiModelProperty("业务日期")
    private Date businessDate;

    @ApiModelProperty("到期提醒时间")
    private LocalDateTime remindDateTime;

    @ApiModelProperty("到期提醒日期")
    private LocalDate remindDate;

    @ApiModelProperty("是否已发送提醒 0 否; 1 是")
    private Integer remindedOrNot = 0;

    @ApiModelProperty("是否已进入消息队列 0 否; 1 是")
    private Integer queueOrNot = 0;

    //通用字段
    @org.springframework.data.annotation.CreatedBy
    @ApiModelProperty("创建人")
    @JsonIgnore
    private Long createBy;

    @org.springframework.data.annotation.CreatedDate
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    @org.springframework.data.annotation.LastModifiedBy
    @ApiModelProperty("更新人")
    @JsonIgnore
    private Long updateBy;

    @org.springframework.data.annotation.LastModifiedDate
    @ApiModelProperty("更新时间")
    @JsonIgnore
    private LocalDateTime updateTime;

    @ApiModelProperty("租户")
    private Long tenentId;

    @ApiModelProperty("组织机构代码")
    private String orgCode;

    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;

    @ApiModelProperty("关联检查/检测/保养记录")
    private Long recordId;
}
